<?php
session_start();
	$_SESSION['data'] = 'displayAllAdvertise';
	
	require_once '../lib/sql.utils.php';
	
	$sql_util = new SqlUtils();
	$result = $sql_util -> getRows('SELECT * FROM advertises');
	$temp = '
		<div class="menu">
			Quản lý quảng cáo > Danh sách các quảng cáo
		</div>
		<hr />
		<div class="findbox">
			<select>
				<option>Tên Quảng cáo</option>
				<option>Link quảng cáo</option>
			</select>
			<input type="text" size="25" placeholder="Search..."/>
			<input type="button" value="Tìm kiếm"/>
		</div>
		<hr />
		<table border="0" class="detail">
			<tr class = "detail-head">
				<th>STT</th>
				<th>Tên Quảng cáo</th>
				<th>Ảnh</th>
				<th>Link</th>
				<th>Sửa</th>
				<th><input type="checkbox" id="check"></th>
			</tr>';
			
	for ($i=0; $i < count($result); $i++) { 
		$temp .= '<tr class="detail-main">';
			$temp .= '<td>'. ($i+1) .'</td>';
			$temp .= '<td>'.$result[$i]['advertiseName'].'</td>';
			$temp .= '<td><img src="../images/advertise/'.$result[$i]['advertiseImage'].'" width="40px" heigh = "65px" /></td>';
			
			$temp .= '<td>'.'<a href="'.$result[0]['advertiseLink'].'">'.$result[$i]['advertiseLink'].'</a>'.'</td>';
			$temp .= '<td>'.'<a onclick="displayFormEditAdvertise('.$result[$i]['advertiseId'].')">Sửa</a>'.'</td>';
			$temp .= '<td>'.'<input type="checkbox" name="check[]">'.'</td>';
		$temp .= '</tr>';
	}
	$temp .= '</table>';
	$temp .= 'Số lượng dòng hiển thị:';
	$temp .= '<select>
				<option>10</option>
				<option>20</option>
				<option>50</option>
			</select>';
	echo $temp;
?>